package com.zkthink.ceres.promotion.dao;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zkthink.base.R;
import com.zkthink.base.mapper.SuperMapper;
import com.zkthink.ceres.promotion.dto.SalesOrderPageDTO;
import com.zkthink.ceres.promotion.entity.SalesOrder;

import com.zkthink.ceres.promotion.vo.admin.SalesOrderPageVO;
import java.io.File;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * Mapper 接口
 * 分销员
 * </p>
 *
 * @author kellen
 * @date 2020-08-22
 */
@Repository
public interface SalesOrderMapper extends SuperMapper<SalesOrder> {

  @SqlParser(filter = true)
  IPage<SalesOrderPageVO> page(IPage page, @Param("param") SalesOrderPageDTO model);

  /**
   * 根据分销员id和店铺编码查询分销员在该店铺的收益
   * @param mid
   * @param sid
   * @param tenantCode
   * @return
   */
  @SqlParser(filter = true)
  Long selectOrderSumByMidAndSidAndTenantCode(@Param("mid")Long mid, @Param("sid")Long sid, @Param("tenantCode")String tenantCode);

  /**
   * 查询某个指定下级分销员在某家店铺的间接佣金
   * @param profitSid
   * @param tenantCode
   * @return
   */
  @SqlParser(filter = true)
  Long selectCommissionSumByProfitSidAndTenantCode(@Param("profitSid") Long profitSid, @Param("tenantCode") String tenantCode, @Param("settleStatus")Integer settleStatus, @Param("type") Integer type);

  /**
   * 查询间接佣金
   * @param sid
   * @param profitSid
   * @param tenantCode
   * @return
   */
  @SqlParser(filter = true)
  Long selectIndirectCommission(@Param("sid") Long sid, @Param("profitSid") Long profitSid, @Param("tenantCode") String tenantCode);
}
